package com.sunny.dict;

import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MDict
{
  private static String a = "<html><head>";
  private static String b = "<style type=\"text/css\">@font-face {font-family:Kingsoft Phonetic Plain; src: url('file:///android_asset/fonts/WSEnVoice.ttf')}";
  private static String c = "</style></head>";
  private static String d = "\n<body>";
  private static String e = "\n</body></html>";

  public static String a(int paramInt, String paramString)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    String str1 = getKeywordContent(paramInt, paramString);
    if (str1 == null)
      str1 = "";
    Object localObject = str1;
    int i = 3;
    String[] arrayOfString;
    int j;
    label79: HashMap localHashMap;
    int k;
    if ((((String)localObject).length() <= 8) || (!(((String)localObject).startsWith("@@@LINK="))) || (i <= 0))
    {
      a();
      arrayOfString = ((String)localObject).split("`");
      if (((String)localObject).split("<[b|B][r|R]\\s+(?:[^>]*)>").length <= 1)
        break label202;
      j = 1;
      localHashMap = new HashMap();
      if (arrayOfString.length <= 2)
        break label387;
      k = 0;
      label98: if (k < arrayOfString.length)
        break label208;
    }
    while (true)
    {
      label106: a(localHashMap);
      return localStringBuilder.toString();
      --i;
      String str4 = ((String)localObject).substring(8).trim();
      String str5 = getKeywordContent(paramInt, str4);
      if (str5 == null)
        str5 = "";
      int i1;
      if (str5.equals(""))
        i1 = -5 + getNearestKeywordID(paramInt, str4);
      for (int i2 = 0; ; ++i2)
      {
        if (i2 >= 10)
          localObject = str5;
        getKeywordByID(paramInt, ++i1);
      }
      label202: j = 0;
      break label79:
      label208: if (k == 0);
      try
      {
        if (arrayOfString[k].trim().equals(""))
          ++k;
        int l = Integer.valueOf(arrayOfString[k]).intValue();
        localStringBuilder.append(getDictMarkerValue(paramInt, l, true));
        String str3 = arrayOfString[(k + 1)];
        if (j != 0)
        {
          localStringBuilder.append(a(str3, localHashMap));
          localStringBuilder.append(getDictMarkerValue(paramInt, l, false));
          k += 2;
        }
        label387: localStringBuilder.append(a(a(str3, "\n", "<br/>"), localHashMap));
      }
      catch (Exception localException)
      {
        localStringBuilder.append("`");
        String str2 = arrayOfString[k];
        if (j != 0)
          localStringBuilder.append(a(str2, localHashMap));
        while (true)
        {
          ++k;
          break label98:
          localStringBuilder.append(a(a(str2, "\n", "<br/>"), localHashMap));
        }
        if (j != 0)
          localStringBuilder.append(a((String)localObject, localHashMap));
        localStringBuilder.append(a(a((String)localObject, "\n", "<br/>"), localHashMap));
        break label106:
      }
    }
  }

  private static String a(String paramString1, String paramString2, String paramString3)
  {
    String str3;
    if (paramString1.length() == 0)
    {
      str3 = "";
      return str3;
    }
    String str1 = "";
    int i;
    for (String str2 = paramString1; ; str2 = str2.substring(i + paramString2.length(), str2.length()))
    {
      do
      {
        if (str2.indexOf(paramString2) == -1)
          str3 = str1 + str2;
        i = str2.indexOf(paramString2);
      }
      while (i == str2.length());
      str1 = str1 + str2.substring(0, i) + paramString3;
    }
  }

  private static String a(String paramString, HashMap paramHashMap)
  {
    Matcher localMatcher = Pattern.compile("<[i|I][m|M][g|G]\\s+(?:[^>]*)[s|S][r|R][c|C]\\s*=\\s*([^>]+)>").matcher(paramString);
    StringBuffer localStringBuffer = new StringBuffer();
    if (!(localMatcher.find()))
    {
      label18: localMatcher.appendTail(localStringBuffer);
      return localStringBuffer.toString();
    }
    String str1 = localMatcher.group();
    String[] arrayOfString1 = str1.split("[s|S][r|R][c|C]\\s*=");
    String[] arrayOfString5;
    if (arrayOfString1.length > 0)
    {
      str2 = arrayOfString1[(arrayOfString1.length - 1)].trim();
      if (str2.startsWith("'"))
      {
        arrayOfString5 = str2.split("'");
        if (arrayOfString5.length <= 1);
      }
    }
    for (String str2 = arrayOfString5[1]; ; str2 = "")
    {
      label102: StringBuilder localStringBuilder = new StringBuilder();
      String str3 = str2.trim();
      if (str3.indexOf(58) < 0)
      {
        localStringBuilder.append("<img src=\"file:///sdcard/wordstudy/temp/");
        localStringBuilder.append(str3);
        if (!(paramHashMap.containsKey(str3)))
          paramHashMap.put(str3, str3);
        localStringBuilder.append("\">");
      }
      while (true)
      {
        localMatcher.appendReplacement(localStringBuffer, localStringBuilder.toString());
        break label18:
        if (str2.startsWith("\""))
        {
          String[] arrayOfString4 = str2.split("\"");
          if (arrayOfString4.length > 1);
          str2 = arrayOfString4[1];
        }
        String[] arrayOfString2 = str2.split(" ");
        if (arrayOfString2.length > 1)
          str2 = arrayOfString2[0];
        String[] arrayOfString3 = str2.split(">");
        if (arrayOfString3.length > 0);
        str2 = arrayOfString3[0];
        break label102:
        localStringBuilder.append(str1);
      }
    }
  }

  private static void a()
  {
    File localFile1 = new File("/sdcard/wordstudy/");
    if (!(localFile1.exists()))
      localFile1.mkdirs();
    File localFile2 = new File("/sdcard/wordstudy/temp/");
    if (!(localFile2.exists()))
      localFile2.mkdirs();
    String[] arrayOfString = localFile2.list();
    if (arrayOfString != null);
    for (int i = 0; ; ++i)
    {
      if (i >= arrayOfString.length)
        return;
      String str = arrayOfString[i];
      File localFile3 = new File("/sdcard/wordstudy/temp/" + str);
      if (!(localFile3.isFile()))
        continue;
      localFile3.delete();
    }
  }

  private static void a(HashMap paramHashMap)
  {
    Iterator localIterator = paramHashMap.values().iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
        return;
      String str = (String)localIterator.next();
      if (str.startsWith("\\"))
        saveMDDResToFile(str, "/sdcard/wordstudy/temp" + a(str, "\\", "/"));
      saveMDDResToFile("\\" + str, "/sdcard/wordstudy/temp/" + a(str, "\\", "/"));
    }
  }

  public static boolean a(String paramString)
  {
    return paramString.equalsIgnoreCase("Title (No HTML code allowed)");
  }

  public static String b(String paramString)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append(a);
    localStringBuilder.append(b);
    localStringBuilder.append(c);
    localStringBuilder.append(d);
    localStringBuilder.append(paramString);
    localStringBuilder.append(e);
    return localStringBuilder.toString();
  }

  public static native void clearDictMemoryBuffer(int paramInt);

  public static native int getDictCount();

  public static native int getDictDataCount(int paramInt);

  public static native String getDictDesc(int paramInt);

  public static native String getDictFileName(int paramInt);

  public static native int getDictIDByFileName(String paramString);

  public static native String getDictMarkerValue(int paramInt1, int paramInt2, boolean paramBoolean);

  public static native String getDictTitle(int paramInt);

  public static native String getKeywordByID(int paramInt1, int paramInt2);

  public static native String getKeywordContent(int paramInt, String paramString);

  public static native int getMddCount();

  public static native int getNearestKeywordID(int paramInt, String paramString);

  public static native void refreshDictList();

  public static native boolean saveMDDResToFile(String paramString1, String paramString2);

  public static native void setMddsWithDictID(int paramInt);
}

/* Location:           E:\Desktop\Android\wordstd\classes_dex2jar.jar
 * Qualified Name:     com.sunny.dict.MDict
 * JD-Core Version:    0.5.3
 */